package 字符串;

/*
 * 分割字符串：
 *   public String[] split(String regex);    按照参数的规则，将字符串切割成若干部分
 *
 *注意：
 * split方法的参数是一个"正则表达式"，英文句号"."须写成"\\."
 *
 * */
public class 字符串分割 {
    public static void main(String[] args) {

        String str1 = "AAA,BBB,CCC,DDD";
        String[] a = str1.split(",");
        for (int i = 0; i < a.length; i++) {
            System.out.println(a[i]);
        }

        System.out.println("***********************");

        String str2 = "AAA BBB CCC DDD";
        String[] b = str2.split(" ");
        for (int j = 0; j < a.length; j++) {
            System.out.println(a[j]);
        }

        System.out.println("***********************");

        String str3 = "AAA.BBB.CCC.DDD";
        String[] c = str3.split("\\.");
        // String[] c = str3.split(".");
        System.out.println(c.length);
        for (int j = 0; j < a.length; j++) {
            System.out.println(c[j]);
        }

    }
}
